"use client"
import { useEffect, useRef } from 'react';

export default function Home() {
    const fileInputRef = useRef(null);

    const handleSubmit = async (e) => {
        e.preventDefault();
        const formData = new FormData();
        formData.append('file', fileInputRef.current.files[0]);

        try {
            const response = await fetch('/api/upload', {
                method: 'POST',
                body: formData,
            });

            const data = await response.json();
            console.log(data);
        } catch (error) {
            console.error(error);
        }
    };

    return (
        <div>
            <form onSubmit={handleSubmit}>
                <input type="file" ref={fileInputRef} />
                <button type="submit">Upload</button>
            </form>
        </div>
    );
}